package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Orders;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

public interface OrderMapper {

    /**
     * 订单分页查询
     * @param number
     * @param orderBeginTime
     * @param orderEndTime
     * @return
     */
    List<Orders> findOrderPage(String number, LocalDateTime orderBeginTime, LocalDateTime orderEndTime);


    int insertOrders(Orders orders);

    @Select("select * from orders where user_id = #{id} order by checkout_time desc")
    List<Orders> findOrderByUserId(long id);

    @Update("update orders set status = #{status},checkout_time = #{checkoutTime} where number = #{number}")
    int updateOrderIsPay(Orders orders);

    @Select("select * from orders where number = #{number}")
    Orders findOrderByNumber(String number);
}
